/*
 * ImageFilter.java
 *
 * Created on August 6, 2004, 10:42 PM
 */

/**
 *
 * @author  pablo
 */
package edu.umd.essic.maskbuilder;

import java.io.File;
import javax.swing.*;
import javax.swing.filechooser.*;

public class FilesFilter extends FileFilter {
    private int filetype; //1 - image, 2 - txt, 3 - dat, 4 - dym, 5 - g98, 6 - bin, 7 - par
    // Accept all directories and all gif, jpg, or tiff files.
    public FilesFilter(int ft){
        filetype = ft;
    }
    public boolean accept(File f) {
        if (f.isDirectory()) {
            return true;
        }
        String extension = Utils.getExtension(f);
	if (extension != null) {
            if ((extension.equals(Utils.gmb)) && (filetype == 1)) {
                    return true;
            } else if (extension.equals(Utils.txt) && (filetype == 2)){
                    return true;
            } else if (extension.equals(Utils.dat) && (filetype == 3)){
                    return true;
            } else if (extension.equals(Utils.dym) && (filetype == 4)){
                    return true;
            } else if (extension.equals(Utils.g98) && (filetype == 5)){
                    return true;
            } else if (extension.equals(Utils.bin) && (filetype == 6)){
                    return true;
            } else if (extension.equals(Utils.par) && (filetype == 7)){
                    return true;
            }
              else return false;
    	}

        return false;
    }
    
    // The description of this filter
    public String getDescription() {
        if (filetype == 1)
            return "GMB files";
        if (filetype == 2)
            return "Text files";
        if (filetype == 3)
            return "Dat files";
        if (filetype == 4)
            return "Dym files";
        if (filetype == 5)
            return "GEODAS files";
        if (filetype == 6)
            return "Fishery files";
        if (filetype == 7)
            return "Parameter files";        
        else return null;
    }
}
